<?php


namespace app\common\model;


class User extends BaseModel
{
    protected $type = [
        "area" => 'array'
    ];
    public function __construct(array $data = [])
    {
        parent::__construct($data);
    }

    public function getHeadimgAttr($value,$data)
    {
        if (empty($value)) return  '';
        if (substr($value,0,4) == "http") {
            return $value;
        } else {
            return request()->domain() . $value;
        }
    }

    public function getInviteAttr($value,$data)
    {
         $money = MoneyLog::where('user_id',$data['id'])
            ->where('is_invite',1)
            ->sum('money');
         return round($money,2);
    }

}